<?
session_start();
if(($_SESSION['datos_admin']['estado'] == "autenticado") && ($_SESSION['datos_admin']['tipo'] == 3)) {

include("header.php");
include(XOOPS_ROOT_PATH."/header.php");
//
$mydirname = basename( dirname( __FILE__ ) ) ;
	
global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsTpl, $mid, $mydirname;
	
require_once( XOOPS_ROOT_PATH."/modules/$mydirname/include/gtickets.php" ) ;
include(XOOPS_ROOT_PATH."/modules/$mydirname/include/functions.php");

$myts =& MyTextSanitizer::getInstance();
$module_id = $xoopsModule->getVar('mid');


$GLOBALS['xoopsOption']['template_main'] = "jobs_principalempresas.html";

$login_empresa = $_SESSION['datos_admin']['user'];

$result = $xoopsDB->query("select empresa FROM ".$xoopsDB->prefix("jobs_empresas")." WHERE login='{$login_empresa}'");
list($empresa) = $xoopsDB->fetchRow($result); 

$xoopsTpl->assign('xmid', $xoopsModule->getVar('mid'));
$xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']);
$xoopsTpl->assign('add_from_title', _TITLE_EMPRESAS );
$xoopsTpl->assign('salir',"<a href='salir.php'>"._SALIR."&nbsp;<img src=\"images/exit.png\" border=0 alt=\""._SALIR2."\" width=\"30\" height=\"20\" /></a>");
$xoopsTpl->assign('empresa', $empresa);
$xoopsTpl->assign('ofertas', "<a href='addlisting.php'><img src=\"images/newred.gif\" border=0 alt=\""._JOBS_ADDLISTING2."\" />&nbsp;"._JOBS_ADDLISTING."</a>");
$xoopsTpl->assign('modificar_oferta', "<a href='hojasde_vida.php'><img src=\"images/friend.gif\" border=0 alt=\""._VER_RESUMES2."\" />&nbsp;"._VER_RESUMES."</a>");
$xoopsTpl->assign('modificar_empresa', "<a href='modempresa.php?op=ModEmpresa&amp;login_empresa=$login_empresa'><img src=\"images/edit.gif\" border=0 alt=\""._MOD_EMPRESA2."\" />&nbsp;"._MOD_EMPRESA."</a>");
$xoopsTpl->assign('reportar', "<a href='reporte.php'><img src=\"images/photo.gif\" border=0 alt=\""._REPORTAR2."\" />&nbsp;"._REPORTAR."</a>");

$xoopsTpl->assign('bienvenida', _BIENVENIDA);
$xoopsTpl->assign('info_ofertas', _EMPRESA_HEAD);
$xoopsTpl->assign('info_borrar', _EMPRESA_HEAD6);
$xoopsTpl->assign('info_ofertas2', _EMPRESA_HEAD3);
$xoopsTpl->assign('info_actempresa', _EMPRESA_HEAD2);
$xoopsTpl->assign('info_reporte', _EMPRESA_HEAD4);

//
	include_once(XOOPS_ROOT_PATH."/class/xoopstree.php");
		
	$resultx=$xoopsDB->query("select lid, title, exprequerida, programa, expire, type, company, price, typeprice, date, submitter, town, valid, photo, view FROM ".$xoopsDB->prefix("jobs_listing")." WHERE submitter=$login_empresa AND valid='Yes' ORDER BY date DESC ");
	$recordexist = $xoopsDB->getRowsNum($resultx);
	$xoopsTpl->assign('ad_exists', $recordexist);
	if ($recordexist){
	    $xoopsTpl->assign('mis_ofertas', _MIS_OFERTAS."$empresa");
		$xoopsTpl->assign('last_head_title', _JOBS_TITLE);
		$xoopsTpl->assign('last_head_company', _SAL2);
		$xoopsTpl->assign('last_head_date', _JOBS_DATE);
		$xoopsTpl->assign('last_head_local', _EXPER);
		$xoopsTpl->assign('last_head_date2', _EXPIRA);
		
		$rank = 1;
	
		while(list($lid, $title, $exprequerida, $programa, $expire, $type, $company, $price, $typeprice, $date, $submitter, $town, $valid, $photo, $vu)=$xoopsDB->fetchRow($resultx)) {
				
			$a_item = array();

			$useroffset = $xoopsConfig['default_TZ'];
		
			$date = ($useroffset*3600) + $date;
			$date2 = $date + ($expire*86400);
			$date = formatTimestamp($date,"s");
			$date2 = formatTimestamp($date2,"s");
			$price = number_format($price,0,",",".");

			$a_item['borrar'] = "<a href='modjob.php?op=DelJob&amp;lid=$lid'><img src=\"images/dele.gif\" border=0 alt=\""._CAL_SUPPRANN."\" /></a>";
            $a_item['title'] = "<a href='modjob.php?op=ModJob&amp;lid=$lid'>$title</a>";
			$a_item['company'] = "".$xoopsModuleConfig['monnaie']." $price";									
			$a_item['local'] = $exprequerida;
			$a_item['date'] = $date;
			$a_item['date2'] = $date2;

			$rank++;
			$xoopsTpl->append('items', $a_item);
		}
	}
	else {
    	$xoopsTpl->assign('no_ad', _NOPUBLICACION);
    }

/**
 * Funci�n para borrar las ofertas de la bandeja de entrada de las empresas cuando se cumple la fecha de expiraci�n
 */
ExpireJob();
//

echo "<br /><br />
<div align=\"center\">" . _INFO_PAG . "</div>
<br /><br />";


include(XOOPS_ROOT_PATH."/footer.php");
}else
{
// Usuario que no se ha logueado
echo "No tienes permiso para entrar a esta p�gina...";
exit();
}  
?>